# -*- coding:utf-8 -*-
# 2022/1/28 15:56
# author:xwl
from fastapi import APIRouter, Depends

from backend.app.app.models.effect_pridict.base_infomation import save_tb_year_dvpunit_oilstim_planproj_forecast_model, \
    save_tb_oilwellstim_planproj_forecast_model, \
    save_tb_year_dvpunit_planproj_oilstim_cost_model, save_tb_year_dvpunit_planproj_oilprice_model, \
    save_tb_year_dvpunit_oilstim_planproj_basic_datas, save_tb_year_dvpunit_oilstim_planproj_forecast_datas, \
    save_tb_oilwellstim_planproj_forecast_datas, save_tb_year_dvpunit_planproj_oilstim_cost_datas, \
    save_tb_year_dvpunit_planproj_oilprice_datas, \
    save_tb_year_dvpunit_planproj_discount_datas, save_tb_year_dvpunit_oilstim_planproj_evaluate_result_datas, \
    save_well_proj_evaluate_result_datas, save_tb_year_dvpunit_oilsalecost_ratio_datas, \
    save_tb_year_dvpunit_planproj_oilprodcost_datas
from backend.app.app.api.api_v1.user import verify_token_user
from backend.app.app.crud_pub.data_manage_db import read_tb_year_dvpunit_oilstim_planproj_basic, \
    save_tb_year_dvpunit_oilstim_planproj_basic, read_tb_year_dvpunit_oilstim_planproj_forecast, \
    save_tb_year_dvpunit_oilstim_planproj_forecast, read_tb_oilwellstim_planproj_forecast, \
    save_tb_oilwellstim_planproj_forecast, read_tb_year_dvpunit_planproj_oilstim_cost, \
    save_tb_year_dvpunit_planproj_oilstim_cost, read_tb_year_dvpunit_planproj_oilprice, \
    save_tb_year_dvpunit_planproj_oilprice, read_tb_year_dvpunit_planproj_discount, \
    save_tb_year_dvpunit_planproj_discount, read_tb_year_dvpunit_oilstim_planproj_evaluate_result, \
    save_tb_year_dvpunit_oilstim_planproj_evaluate_result, read_tb_oilwellstim_planproj_evaluate_result, \
    save_tb_oilwellstim_planproj_evaluate_result, read_tb_year_dvpunit_oilsalecost_ratio, \
    save_tb_year_dvpunit_oilsalecost_ratio, read_tb_year_dvpunit_planproj_oilprodcost, \
    save_tb_year_dvpunit_planproj_oilprodcost

from backend.app.app.api.api_Hu.crud.pub.data_manage import *
from backend.app.app.api.api_Hu.models.data_manage import *

data_management = APIRouter(prefix="/data_management", tags=["数据管理"])


@data_management.post("/read_basic_information_of_scheme_measures", name="方案措施基本信息-读库")
async def read_basic_information_of_scheme_measures(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_oilstim_planproj_basic()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_basic_information_of_scheme_measures", name="方案措施基本信息-存库")
async def save_basic_information_of_scheme_measures(datas: save_tb_year_dvpunit_oilstim_planproj_basic_datas,ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_oilstim_planproj_basic(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/read_prediction_effect_of_unit_scheme", name="单元方案预测效果-读库")
async def read_prediction_effect_of_unit_scheme(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_oilstim_planproj_forecast()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_prediction_effect_of_unit_scheme", name="单元方案预测效果-存库")
async def save_prediction_effect_of_unit_scheme(datas: save_tb_year_dvpunit_oilstim_planproj_forecast_datas,ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_oilstim_planproj_forecast(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/read_prediction_effect_of_well_scheme", name="单井方案预测效果-读库")
async def read_prediction_effect_of_well_scheme(ver=Depends(verify_token_user)):
    result = read_tb_oilwellstim_planproj_forecast()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_prediction_effect_of_well_scheme", name="单井方案预测效果-存库")
async def save_prediction_effect_of_well_scheme(datas: save_tb_oilwellstim_planproj_forecast_datas,ver=Depends(verify_token_user)):
    result = save_tb_oilwellstim_planproj_forecast(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/read_operation_cost_of_scheme_measures", name="方案措施作业费用-读库")
async def read_operation_cost_of_scheme_measures(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_planproj_oilstim_cost()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_operation_cost_of_scheme_measures", name="方案措施作业费用-存库")
async def save_operation_cost_of_scheme_measures(datas: save_tb_year_dvpunit_planproj_oilstim_cost_datas,
                                                 ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_planproj_oilstim_cost(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/read_scheme_measures_crude_oil_price", name="方案措施原油价格-读库")
async def read_scheme_measures_crude_oil_price(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_planproj_oilprice()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_scheme_measures_crude_oil_price", name="方案措施原油价格-存库")
async def save_scheme_measures_crude_oil_price(datas: save_tb_year_dvpunit_planproj_oilprice_datas,
                                               ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_planproj_oilprice(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }

@data_management.post("/read_proj_increase_oil_operation_cost", name="方案增油操作成本-读库")
async def read_proj_increase_oil_operation_cost(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_planproj_oilprodcost()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_proj_increase_oil_operation_cost", name="方案增油操作成本-存库")
async def save_proj_increase_oil_operation_cost(datas:save_tb_year_dvpunit_planproj_oilprodcost_datas,ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_planproj_oilprodcost(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }

@data_management.post("/read_proj_increase_oil_sales_cost", name="方案增油销售成本-读库")
async def read_proj_increase_oil_sales_cost(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_oilsalecost_ratio()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_proj_increase_oil_sales_cost", name="方案增油销售成本-存库")
async def save_proj_increase_oil_sales_cost(datas:save_tb_year_dvpunit_oilsalecost_ratio_datas,ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_oilsalecost_ratio(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }

@data_management.post("/read_proj_capital_cost", name="方案资金成本-读库")
async def read_proj_capital_cost(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_planproj_discount()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_proj_capital_cost", name="方案资金成本-存库")
async def save_proj_capital_cost(datas:save_tb_year_dvpunit_planproj_discount_datas,ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_planproj_discount(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }

@data_management.post("/read_dvp_proj_evaluate_result", name="单元方案经济评价结果-读库")
async def read_dvp_proj_evaluate_result(ver=Depends(verify_token_user)):
    result = read_tb_year_dvpunit_oilstim_planproj_evaluate_result()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_dvp_proj_evaluate_result", name="单元方案经济评价结果-存库")
async def save_dvp_proj_evaluate_result(datas:save_tb_year_dvpunit_oilstim_planproj_evaluate_result_datas,ver=Depends(verify_token_user)):
    result = save_tb_year_dvpunit_oilstim_planproj_evaluate_result(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }

@data_management.post("/read_well_proj_evaluate_result", name="单井方案经济评价结果-读库")
async def read_well_proj_evaluate_result(ver=Depends(verify_token_user)):
    result = read_tb_oilwellstim_planproj_evaluate_result()
    return {
        'result': result,
        "verify": ver
    }


@data_management.post("/save_well_proj_evaluate_result", name="单井方案经济评价结果-存库")
async def save_well_proj_evaluate_result(datas:save_well_proj_evaluate_result_datas,ver=Depends(verify_token_user)):
    result = save_tb_oilwellstim_planproj_evaluate_result(datas.save,datas.modify,datas.delete)
    return {
        'result': result,
        "verify": ver
    }

"""
下为hzc编写的接口
"""


@data_management.post("/read_dvp_unit_basic", name="单元基本信息-读库")
async def read_dvp_unit_basic(ver=Depends(verify_token_user)):
    data = read_unit_basic_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_dvp_unit_basic", name="单元基本信息-存库")
async def save_dvp_unit_basic(input_data: DvpUnitBasic, ver=Depends(verify_token_user)):
    result = save_unit_basic_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_well_basic", name="单井基本信息-读库")
async def read_well_basic(ver=Depends(verify_token_user)):
    data = read_well_basic_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_well_basic", name="单井基本信息-存库")
async def save_well_basic(input_data: WellBasic, ver=Depends(verify_token_user)):
    result = save_well_basic_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_oil_well_stimulate", name="措施分类信息-读库")
async def read_oil_well_stimulate(ver=Depends(verify_token_user)):
    data = read_oil_well_stimulate_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_oil_well_stimulate", name="措施分类信息-存库")
async def save_oil_well_stimulate(input_data: OilWellStimulate, ver=Depends(verify_token_user)):
    result = save_oil_well_stimulate_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_unit_stimulate_result", name="单元措施效果-读库")
async def read_unit_stimulate_result(ver=Depends(verify_token_user)):
    data = read_unit_stimulate_result_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_unit_stimulate_result", name="单元措施效果-存库")
async def save_unit_stimulate_result(input_data: UnitStimulateResult, ver=Depends(verify_token_user)):
    result = save_unit_stimulate_result_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_well_stimulate_result", name="单井措施效果-读库")
async def read_well_stimulate_result(ver=Depends(verify_token_user)):
    data = read_well_stimulate_result_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_well_stimulate_result", name="单井措施效果-存库")
async def save_well_stimulate_result(input_data: WellStimulateResult, ver=Depends(verify_token_user)):
    result = save_well_stimulate_result_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_stimulate_cost", name="措施作业费用-读库")
async def read_stimulate_cost(ver=Depends(verify_token_user)):
    data = read_stimulate_cost_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_stimulate_cost", name="措施作业费用-存库")
async def save_stimulate_cost(input_data: StimulateCost, ver=Depends(verify_token_user)):
    result = save_stimulate_cost_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_unit_oil_price", name="单元原油价格-读库")
async def read_unit_oil_price(ver=Depends(verify_token_user)):
    data = read_unit_oil_price_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_unit_oil_price", name="单元原油价格-存库")
async def save_unit_oil_price(input_data: UnitOilPrice, ver=Depends(verify_token_user)):
    result = save_unit_oil_price_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_oil_operate_cost", name="增油操作成本-读库")
async def read_oil_operate_cost(ver=Depends(verify_token_user)):
    data = read_oil_operate_cost_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_oil_operate_cost", name="增油操作成本-存库")
async def save_oil_operate_cost(input_data: OilOperateCost, ver=Depends(verify_token_user)):
    result = save_oil_operate_cost_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_oil_sale_cost", name="增油销售成本-读库")
async def read_oil_sale_cost(ver=Depends(verify_token_user)):
    data = read_oil_sale_cost_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_oil_sale_cost", name="增油销售成本-存库")
async def save_oil_sale_cost(input_data: OilSaleCost, ver=Depends(verify_token_user)):
    result = save_oil_sale_cost_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_cost", name="资金成本-读库")
async def read_cost(ver=Depends(verify_token_user)):
    data = read_cost_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_cost", name="资金成本-存库")
async def save_cost(input_data: Cost, ver=Depends(verify_token_user)):
    result = save_cost_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_unit_stimulate_evaluate_result", name="单元经济评价结果-读库")
async def read_unit_stimulate_evaluate_result(ver=Depends(verify_token_user)):
    data = read_unit_stimulate_evaluate_result_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_unit_stimulate_evaluate_result", name="单元经济评价结果-存库")
async def save_unit_stimulate_evaluate_result(input_data: UnitStimulateEvaluateResult, ver=Depends(verify_token_user)):
    result = save_unit_stimulate_evaluate_result_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }


@data_management.post("/read_well_stimulate_evaluate_result", name="单井经济评价结果-读库")
async def read_well_stimulate_evaluate_result(ver=Depends(verify_token_user)):
    data = read_well_stimulate_evaluate_result_data()
    return {
        "data": data,
        "verify": ver
    }


@data_management.post("/save_well_stimulate_evaluate_result", name="单井经济评价结果-存库")
async def save_well_stimulate_evaluate_result(input_data: WellStimulateEvaluateResult, ver=Depends(verify_token_user)):
    result = save_well_stimulate_evaluate_result_data(
        save=input_data.save,
        modify=input_data.modify,
        delete=input_data.delete
    )
    return {
        "result": result,
        "verify": ver
    }
